import Vue from 'vue'
import VueRouter from "vue-router"

import NotFound from "@/views/NotFound"
import store from '@/store/index'
import {userRouter} from "./user";
import {adminRouter} from "./admin";
import HomePage from "../views/admin/HomePage";

Vue.use(VueRouter)

// 页面跳转逻辑
let routes = [
  // 404页面
  {path: '*', name: 'NotFound', component: NotFound},
  ...userRouter(),
  ...adminRouter(),
]
const router = new VueRouter({
  mode: "history",
  routes
})
// 全局路由守卫,实现前端登录拦截
router.beforeEach((to, from, next) => {
  if (to.meta.requiresAuth){

    next()
    /*路由验证*/
  }else {
    next()
  }
  // if (to.path === '/login')return next();
  // store.state.token?next():next({path:"/login"});
})
export {router}


